<template>
  <div class="posttable">
    <el-row>
      <el-col :span="24" style="padding-right: 30px;padding-left: 40px;">
        <div class="addform addForm" v-if="form">
          <el-form :label-position="labelPosition" ref="form" :model="form" :rules="rules">
            
            <el-row class="change">
              <el-col :span="5">
                <el-form-item label="客户简称" prop="customerInfo.name" style="margin-bottom: 10px;">
                  <el-input placeholder="请输入客户名简称" v-model.trim="form.customerInfo.name"
                            style="width: 274px" @blur="toAbbreviation"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="5" :offset="1">
                <el-form-item label="客户全称" prop="customerInfo.fullName">
                  <el-input placeholder="请输入客户全称" v-model.trim="form.customerInfo.fullName"
                            style="width: 274px"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="5" :offset="1">
                <el-form-item label="英文简称" prop="customerInfo.abbreviation">
                  <el-input placeholder="请输入英文简称" v-model.trim="form.customerInfo.abbreviation"
                            style="width: 274px"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="5" :offset="1">
                <el-form-item label="负责助理" prop="customerInfo.assistant">
                  <el-select placeholder="请选择助理" v-model.trim="form.customerInfo.assistant">
                    <el-option
                      v-for="item in assistlist"
                      :key="item.username"
                      :label="item.name"
                      :value="item.username">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="5">
                <el-form-item label="有无需求编号" prop="customerInfo.mendChange">
                  
                  <el-select v-model="form.customerInfo.mendChange" placeholder="请选择需求编号">
                    <el-option
                      v-for="item in options"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5" :offset="1">
                <el-form-item label="收件人类型" prop="customerInfo.unifiedInter">
                  
                  <el-select v-model="form.customerInfo.unifiedInter" placeholder="请选择收件人类型" @change="typechange">
                    <el-option
                      v-for="item in options1"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5" :offset="1" v-if="typeshow">
                <el-form-item label="收件人邮箱数量" prop="customerInfo.receiveNum">
                  
                  <el-select v-model="form.customerInfo.receiveNum" placeholder="请选择邮箱数量" @change="receiveNumchange">
                    <el-option
                      v-for="item in options2"
                      :key="item.value"
                      :label="item.value"
                      :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5" :offset="1">
                <el-form-item label="转HR系统" prop="customerInfo.hrSystem">
                  
                  <el-select v-model="form.customerInfo.hrSystem" placeholder="请选择是否转入HR系统">
                    <el-option
                      v-for="item in systemlist"
                      :key="item"
                      :label="item"
                      :value="item">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="5">
                <el-form-item label="负责交付" prop="customerInfo.delivery">
                  <el-select placeholder="请选择交付" v-model.trim="form.customerInfo.delivery">
                    <el-option
                      v-for="(item,index) in deliverylist"
                      :key="index"
                      :label="item"
                      :value="item">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5" :offset="1">
                <el-form-item label="试水客户" prop="customerInfo.testWater">
                  <el-select v-model="form.customerInfo.testWater" placeholder="请选择是否为试水客户" @change="ishuoyue">
                    <el-option label="是" value="是"></el-option>
                    <el-option label="否" value="否"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5" :offset="1" v-if="huoyue == true">
                <el-form-item label="活跃客户" prop="customerInfo.customerActive">
                  <el-select v-model="form.customerInfo.customerActive" placeholder="请选择是否为活跃客户">
                    <el-option label="是" value="是"></el-option>
                    <el-option label="否" value="否"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5" :offset="1" >
                <el-form-item label="接口方式" prop="customerInfo.interfaceMode">
                  <el-select v-model="form.customerInfo.interfaceMode" placeholder="请选择接口方式">
                    <el-option label="电话" value="电话"></el-option>
                    <el-option label="邮件" value="邮件"></el-option>
                    <el-option label="微信" value="微信"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="客户简介" prop="customerInfo.introduction" style="margin-bottom: 10px;">
                  <el-input type="textarea" placeholder="请输入客户简介" v-model.trim="form.customerInfo.introduction"
                            :autosize="{ minRows: 4}"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col>
                <div class="line"></div>
              </el-col>
            </el-row>
            <el-row style="margin-top: 0px;" class="oper">
            </el-row>
            <div v-for="(item,index) in form.customerAddrInfo" :key="index" class="oper1">
              
              <el-row>
                <el-row>
                  <!--办公地点-->
                  <el-col :span="5" v-for="(local,index6) in item.customerAddr" :key="index6"
                          style="margin-right: 4.16667%;">
                    <el-form-item
                      :prop="'customerAddrInfo.' + index +'.customerAddr.'+index6+'.name'"
                      :rules="AddrRules"
                    >
                      <el-col>
                        <span style="color:#333;"><span v-if="item.customerAddr.length !== 1"
                                                        style='color:#F56C6C;'>*</span> 办公地点</span>
                      <i class='el-icon-circle-plus' style="color:#1198ff;font-size: 12px;"
                         v-if="index6 == 0" @click="addlocal(index)"></i>
                      <span v-if="index6 == 0" style="color:#1198ff;font-size: 14px;"
                            @click="addlocal(index)">添加</span>
  
                      <i class='el-icon-circle-close' style="color:#f41f1e;font-size: 12px;"
                         v-if="index6 !== 0" @click="deletelocal(index,index6)"></i>
                      <span style="color:#f41f1e;font-size: 14px;" v-if="index6 !== 0"
                            @click="deletelocal(index,index6)">删除</span>
                    </el-col>
                      <el-input placeholder="请输入办公地点" v-model.trim="local.name"
                                style="width: 274px"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <!--客户联系人部分-->
                <el-row v-for="(item2,index2) in item.manager" :key="index2">
                  <el-col :span="5">
                    <el-form-item
                      :prop="'customerAddrInfo.' + index +'.manager.'+index2+'.name'"
                      :rules="{
      required: true, message: '客户联系人姓名不能为空', trigger: 'blur'
    }"
                    >
                      <!--客户联系人部分-->
                      <el-col>
                        <span style="color:#333;"><span style='color:#F56C6C;'>*</span> 客户联系人</span>
                      </el-col>
                      <el-col>
                        <el-input placeholder="请输入客户联系人姓名" v-model.trim="item2.name"
                                  style="width: 274px"></el-input>
                      </el-col>
                    
                    </el-form-item>
                  
                  </el-col>
                  <el-col :span="5" :offset="1">
                    <el-form-item
                      :prop="'customerAddrInfo.' + index +'.manager.'+index2+'.phone'"
                      :rules="PhoneRules"
                    >
                      <!---->
                      <el-col>
                        <span style="color:#333;"><span style='color:#F56C6C;'>*</span> 联系人电话</span>
                      </el-col>
                      <el-input placeholder="请输入联系人电话" v-model.trim="item2.phone"
                                style="width: 274px"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5" :offset="1">
                    <el-form-item label="联系人邮箱"
                                  :prop="'customerAddrInfo.' + index +'.manager.'+index2+'.email'"
                                  :rules="EmailRules2"
                    >
                      <el-input placeholder="请输入联系人邮箱" v-model.trim="item2.email" style="width: 274px"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <!--收件人和抄送人邮箱-->
                <el-row>
                  <el-col v-if="typeshow" v-for="(item7,index7) in item.rcMail" :key="index7">
                    <el-col :span="5">
                      <el-form-item
                        :prop="'customerAddrInfo.' + index +'.rcMail.'+index7+'.receiveMail'"
                        :rules="EmailRules"
                      >
                        <el-col>
                          <span style="color:#333;"><span style='color:#F56C6C;'>*</span> 收件人邮箱</span>
                        </el-col>
                        <el-input placeholder="请输入收件人邮箱" v-model.trim="item7.receiveMail"
                                  style="width: 274px"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="5" v-for="(item4,index4) in item7.cpSendMail" :key="index4"
                            :class="{'el-col-offset-1' : (index4 !== 3)}">
                      <el-form-item
                        v-if="item7.cpSendMail.length == 1"
                        :prop="'customerAddrInfo.' + index +'.rcMail.'+index7+'.cpSendMail.'+index4+'.mail'"
                        :rules="EmailRules3"
                      >
                        <el-col>
                          <span style="color:#333;"><span v-if="item7.cpSendMail.length !== 1"
                                                          style='color:#F56C6C;'>*</span> 抄送人邮箱</span>
                          <i class='el-icon-circle-plus' style="color:#1198ff;font-size: 12px;"
                             v-if="index4 == 0" @click="addcopymail(index,index7)"></i>
                          <span v-if="index4 == 0" style="color:#1198ff;font-size: 14px;"
                                @click="addcopymail(index,index7)">添加</span>
                          
                          <i class='el-icon-circle-close' style="color:#f41f1e;font-size: 12px;"
                             v-if="index4 !== 0" @click="deletecopymail(index,index7,index4)"></i>
                          <span style="color:#f41f1e;font-size: 14px;" v-if="index4 !== 0"
                                @click="deletecopymail(index,index7,index4)">删除</span>
                        </el-col>
                        <el-input placeholder="请输入抄送人邮箱" v-model.trim="item4.mail" style="width: 274px"></el-input>
                      </el-form-item>
                      <el-form-item
                        v-if="item7.cpSendMail.length > 1"
                        :prop="'customerAddrInfo.' + index +'.rcMail.'+index7+'.cpSendMail.'+index4+'.mail'"
                        :rules="EmailRules1"
                      >
                        <el-col>
                          <span style="color:#333;"><span v-if="item7.cpSendMail.length !== 1"
                                                          style='color:#F56C6C;'>*</span> 抄送人邮箱</span>
                          <i class='el-icon-circle-plus' style="color:#1198ff;font-size: 12px;"
                             v-if="index4 == 0" @click="addcopymail(index,index7)"></i>
                          <span v-if="index4 == 0" style="color:#1198ff;font-size: 14px;"
                                @click="addcopymail(index,index7)">添加</span>
                          
                          <i class='el-icon-circle-close' style="color:#f41f1e;font-size: 12px;"
                             v-if="index4 !== 0" @click="deletecopymail(index,index7,index4)"></i>
                          <span style="color:#f41f1e;font-size: 14px;" v-if="index4 !== 0"
                                @click="deletecopymail(index,index7,index4)">删除</span>
                        </el-col>
                        <el-input placeholder="请输入抄送人邮箱" v-model.trim="item4.mail" style="width: 274px"></el-input>
                      </el-form-item>
                    </el-col>
                  </el-col>
                </el-row>
                
                <el-row>
                  
                  <!--销售信息部分-->
                  <el-col>
                    <el-row v-for="(item3,index3) in item.salesman" :key="index3">
                      <el-col :span="5">
                        <el-form-item
                          style="margin-bottom: 20px;"
                          :prop="'customerAddrInfo.' + index +'.salesman.'+index3+'.name'"
                          :rules="{
      required: true, message: '销售姓名不能为空', trigger: 'blur'
    }"
                        >
                          <el-col>
                            <span style="color:#333;"><span style='color:#F56C6C;'>*</span> 销售姓名</span>
                            <!--添加销售-->
                            <i class='el-icon-circle-plus' style="color:#1198ff;font-size: 12px;"
                               v-if="item3.type == 1" @click="addsale(index)"></i>
                            <span style="color:#1198ff;font-size: 14px;" v-if="item3.type == 1"
                                  @click="addsale(index)">添加</span>
                            <!--删除销售-->
                            <i class='el-icon-circle-close' style="color:#f41f1e;font-size: 12px;"
                               v-if="item3.type == 2" @click="deletesale(index,index3)"></i>
                            <span style="color:#f41f1e;font-size: 14px;" v-if="item3.type == 2"
                                  @click="deletesale(index,index3)">删除</span>
                          </el-col>
                          <el-col>
                            <el-input placeholder="请输入对应销售姓名" v-model.trim="item3.name"
                                      style="width: 274px"></el-input>
                          </el-col>
                        
                        </el-form-item>
                      
                      </el-col>
                      <el-col :span="5" :offset="1">
                        <el-form-item label=""
                                      :prop="'customerAddrInfo.' + index +'.salesman.'+index3+'.phone'"
                                      :rules="PhoneRules"
                        >
                          <el-col>
                            <span style="color:#333;"><span style='color:#F56C6C;'>*</span> 销售电话</span>
                          </el-col>
                          <el-input placeholder="请输入销售电话" v-model.trim="item3.phone" style="width: 274px"></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="5" :offset="1">
                        <el-form-item
                          :prop="'customerAddrInfo.' + index +'.salesman.'+index3+'.mail'"
                          :rules="EmailRules2"
                        >
                          <el-col>
                            <span style="color:#333;">销售邮箱</span>
                          </el-col>
                          <el-input placeholder="请输入销售邮箱" v-model.trim="item3.mail" style="width: 274px"></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-col>
                </el-row>
              </el-row>
            
            </div>
            
            <el-form-item>
              <el-button class="save" :disabled="savedis" @click="submitForm('form')">保存</el-button>
              <el-button class="cancel" @click="cancel('form')">取消</el-button>
            </el-form-item>
          </el-form>
        </div>
      
      </el-col>
    </el-row>
  
  
  </div>
</template>
<script>
  import axios from 'axios'
  import qs from 'qs'
  
  export default {
    name: "employunitadd",
    data() {
      //邮箱必填
      var checkEmail = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('邮箱不能为空'));
        }
        var re = /^[A-Za-z\d]+(([-_.]*)+[A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/;
        
        setTimeout(() => {
          if (value) {
            if (!re.test(value)) {
              callback(new Error('请输入正确的邮箱'));
            } else {
              callback();
            }
          } else {
            callback()
          }
          
        }, 1000);
      };
      //不同条件下的邮箱校验
      var checkEmail1 = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('邮箱不能为空'));
        }
        var re = /^[A-Za-z\d]+(([-_.]*)+[A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/;
        setTimeout(() => {
          if (value) {
            if (!re.test(value)) {
              callback(new Error('请输入正确的邮箱'));
            } else {
              callback();
            }
          } else {
            callback()
          }
          
        }, 1000);
      };
      //只存在一个抄送人邮箱的校验
      var checkEmail3 = (rule, value, callback) => {
        if (value) {
          var re = /^[A-Za-z\d]+(([-_.]*)+[A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/;
          setTimeout(() => {
            if (value) {
              if (!re.test(value)) {
                callback(new Error('请输入正确的邮箱'));
              } else {
                callback();
              }
            } else {
              callback()
            }
            
          }, 1000);
        } else {
          callback()
        }
      };
      //不同条件下的办公地址校验
      var customerAddr = (rule, value, callback) => {
        if (this.form.customerAddrInfo[0].customerAddr.length !== 1) {
          if (!value) {
            return callback(new Error('办公地址不能为空'));
          } else {
            callback()
          }
        } else if (this.form.customerAddrInfo[0].customerAddr.length == 1) {
          callback()
        }
      };
      //校验邮箱的格式
      var checkEmail2 = (rule, value, callback) => {
        
        var re = /^[A-Za-z\d]+(([-_.]*)+[A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/;
        
        setTimeout(() => {
          if (value) {
            if (!re.test(value)) {
              callback(new Error('请输入正确的邮箱'));
            } else {
              callback();
            }
          } else {
            callback()
          }
        }, 1000);
      };
      //校验座机以及手机号
      var checkphone = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('联系方式不能为空'));
        }
        if (value) {
          var re = /(^0\d{2,4}\-\d{7,8}$)|(^1[3|4|5|6|7|8|9][0-9]{9}$)/;
          
          setTimeout(() => {
            
            if (!re.test(value)) {
              callback(new Error('请输入正确的联系方式'));
              return false;
            } else {
              callback();
            }
            
          }, 1000);
        }
      };
      
      return {
        EmailRules: [
          {validator: checkEmail, trigger: 'blur'},
        ],
        EmailRules1: [
          {validator: checkEmail1, trigger: 'blur'},
        ],
        EmailRules3: [
          {validator: checkEmail3, trigger: 'blur'},
        ],
        EmailRules2: [
          {validator: checkEmail2, trigger: 'blur'},
        ],
        AddrRules: [
          {validator: customerAddr, trigger: 'blur'},
        ],
        PhoneRules: [
          {validator: checkphone, trigger: 'blur'},
        ],
        systemlist : ["是","否"],
        huoyue:true,
        form: {
          customerInfo: {
            name: "",
            fullName: "",
            introduction: "",
            mendChange: 0,
            delivery:'无',
            testWater:'否',
            customerActive:'否',
            type: null,
            receiveNum: 1,
            assistant: '',
            hrSystem : '',
            interfaceMode: '',
          },
          customerAddrInfo: [{
            customerAddr: [
              {
                name: ''
              }
            ],
            rcMail: [
              {
                receiveMail: '',
                cpSendMail: [
                  {
                    mail: ''
                  }
                ]
              }
            ],
            manager: [
              {
                name: '',
                phone: '',
                email: ''
              }
            ],
            salesman: [
              {
                name: '',
                phone: '',
                type: 1,
                mail: ''
              }
            ]
          }]
        },
        labelPosition: "top",
        rules: {
          customerInfo: {
            name: [
              {required: true, message: '请输入客户简称', trigger: 'blur'}
            ],
            fullName: [
              {required: true, message: '请输入客户全称', trigger: 'blur'}
            ],
            introduction: [
              {required: true, message: '请输入客户简介', trigger: 'blur'},
              {max: 200, message: '客户简介长度在200字符内', trigger: 'change'},
              {max: 200, message: '客户简介长度在200字符内', trigger: 'blur'}
            ],
            mendChange: [
              {required: true, message: '请选择需求编号', trigger: 'change'}
            ],
            assistant: [
              {required: true, message: '请选择负责助理', trigger: 'change'}
            ],
            unifiedInter: [
              {required: true, message: '请选择收件人类型', trigger: 'change'}
            ],
            receiveMail: [
              {required: true, message: '请输入收件人邮箱', trigger: 'blur'}
            ],
            hrSystem: [
              {required: true, message: '请选择是否转入HR系统', trigger: 'change'}
            ],
            delivery: [
              {required: true, message: '请选择交付', trigger: 'change'}
            ],
            testWater: [
              {required: true, message: '请选择是否为试水客户', trigger: 'change'}
            ],
            customerActive: [
              {required: true, message: '请选择是否为活跃客户', trigger: 'change'}
            ],
            interfaceMode: [
              {required: true, message: '请选择接口方式', trigger: 'change'}
            ],
            abbreviation: [
              {required: true, message: '请输入英文简称', trigger: 'blur'}
            ],
            receiveNum: [
              {required: true, message: '请选择收件人邮箱数量', trigger: 'change'}
            ],
          }
        },
        options: [
          {
            value: 0,
            label: '无'
          }, {
            value: 1,
            label: '有'
          }
        ],
        options1: [
          {
            value: 'Y',
            label: '统一收件人'
          }, {
            value: 'N',
            label: '非统一收件人'
          }
        ],
        options2: [
          {
            value: 1
          }, {
            value: 2
          }, {
            value: 3
          }, {
            value: 4
          }, {
            value: 5
          }, {
            value: 6
          }
        ],
        assistlist: [],
        deliverylist:[],
        typeshow: true,
        savedis : false
      }
    },
    created() {
      this.initdata();
      //获取招聘助理下拉框的数据
      axios.post(this.url + '/employ/getAssistant').then(res => {
        this.unlogin(res.data.code);
        if(res.data.code == 200){
          this.assistlist = res.data.data;
        }
      })
      //获取负责交付下拉框的数据
      axios.get(this.url + "/employ/getjfNames").then(res => {
          this.unlogin(res.data.code);
          if (res.data.code == 200) {
            this.deliverylist = res.data.data;
            this.deliverylist.unshift('无');
          }
        });
    },
    methods: {
      //是否活跃用户
      ishuoyue(){
        if(this.form.customerInfo.testWater == '否'){
          this.huoyue = true;
        }else if(this.form.customerInfo.testWater == '是'){
          this.huoyue = false;
          this.form.customerInfo.customerActive  = '否'
        }
      },
      //转换英文简写
      toAbbreviation() {
        axios.post(this.url + '/employ/toAbbreviation', qs.stringify({
          abbreviation: this.form.customerInfo.name
        })).then(res => {
          this.unlogin(res.data.code);
          this.form.customerInfo.abbreviation = res.data
        })
      },
      //客户类型
      typechange() {
        if (this.form.customerInfo.unifiedInter == "Y") {
          this.typeshow = true
          this.form.customerAddrInfo[0].rcMail[0].cpSendMail = [
            {
              mail: ''
            }
          ];
          this.form.customerAddrInfo[0].rcMail[0].receiveMail = '';
        } else if (this.form.customerInfo.unifiedInter == "N") {
          this.form.customerAddrInfo[0].rcMail[0].cpSendMail = [];
          this.form.customerAddrInfo[0].rcMail[0].receiveMail = '';
          this.typeshow = false
        }
      },
      //收件人邮箱数量设置
      receiveNumchange() {
        var num = this.form.customerInfo.receiveNum;
        var mailnum = this.form.customerAddrInfo[0].rcMail.length;
        var leng = num - mailnum;
        //添加数据
        if (num > mailnum) {
          for (var i = 0; i < leng; i++) {
            this.form.customerAddrInfo[0].rcMail.push({
              receiveMail: '',
              cpSendMail: [
                {
                  mail: ''
                }
              ]
            })
          }
        } else if (num < mailnum) {
          //删除数据
          for (var i = mailnum - 1; i > num - 1; i--) {
            this.form.customerAddrInfo[0].rcMail.splice(i, 1)
          }
        }
      },
      //添加办公地点
      addlocal(index) {
        this.form.customerAddrInfo[index].customerAddr.push({name: ''})
      },
      //删除办公地点
      deletelocal(index, index6) {
        this.form.customerAddrInfo[index].customerAddr.splice(index6, 1)
      },
      //添加抄送人邮箱
      addcopymail(index, index7) {
        if (this.form.customerAddrInfo[index].rcMail[index7].cpSendMail.length < 6) {
          this.form.customerAddrInfo[index].rcMail[index7].cpSendMail.push({mail: ''})
          this.$forceUpdate()
        } else {
          return false
        }
      },
      //删除抄送人邮箱
      deletecopymail(index, index7, index4) {
        this.form.customerAddrInfo[index].rcMail[index7].cpSendMail.splice(index4, 1)
        this.$forceUpdate()
      },
//      添加销售信息
      addsale(index) {
        this.form.customerAddrInfo[index].salesman.push({name: '', phone: '', mail: '', type: 2})
      },
//      删除销售信息
      deletesale(index, index1) {
        this.form.customerAddrInfo[index].salesman.splice(index1, 1)
      },
      //初始化表单数据
      initdata() {
        this.form = {
          customerInfo: {
            name: "",
            fullName: "",
            introduction: "",
            mendChange: 0,
            abbreviation: '',
            delivery:'无',
            testWater:'否',
            customerActive:'否',
            unifiedInter: 'Y',
            receiveNum: 1,
            hrSystem :'',
            interfaceMode: '',
          },
          customerAddrInfo: [
            {
              customerAddr: [
                {
                  name: ''
                }
              ],
              rcMail: [
                {
                  receiveMail: '',
                  cpSendMail: [
                    {
                      mail: ''
                    }
                  ]
                }
              ],
              manager: [
                {
                  name: '',
                  phone: '',
                  email: ''
                }
              ],
              salesman: [
                {
                  name: '',
                  phone: '',
                  type: 1,
                  mail: ''
                }
              ]
            }
          ]
        };
        this.savedis = false;
      },
      //提交数据
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.savedis = true;
            axios.post(this.url + '/employ/saveEmployerList',
              this.form
            ).then(res => {
              this.unlogin(res.data.code);
              if (res.data.code == 200) {
                this.savedis = false;
                this.$emit('getData')
              }
            })
          }
        });
      },
      cancel(formName) {
        this.savedis = false;
        this.$refs[formName].resetFields();
        this.$emit('getData1')
      },
      //清除所有的校验信息
      resetFields(formName) {
        this.$refs[formName].resetFields();
      }
    }
  }
</script>
<style scoped>
  .line {
    border: 0.5px solid #e8e8e8;
    margin-top: 8px;
  }
  
  .oper span {
    font-size: 12px;
  }
  
  .oper i {
    margin-top: 2px;
    line-height: 33px;
  }
  
  .point {
    height: 33px;
    line-height: 33px;
  }
  
  .save {
    width: 150px;
    height: 40px;
    font-size: 16px;
    color: #fff;
    border-radius: 4px;
    margin-right: 43px;
    background: linear-gradient(to bottom, #5696f8 0%, #4e6ef5 100%);
  }
  
  .cancel {
    width: 150px;
    height: 40px;
    border: 1px solid #4e6ef5;
    font-size: 16px;
    font-weight: 500;
    color: #4e6ef5;
  }
  
  .addform {
    color: #333 !important;
  }
  
  .oper i, span {
    cursor: pointer;
    font-weight: 700;
  }
  
  .oper1 i {
    cursor: pointer;
  }
  
  .oper1 span {
    font-weight: 700;
    cursor: pointer;
  }
</style>
